
import 'package:vibration/vibration.dart';

class CYVibrate {
  static vibrate({
    Duration duration = const Duration(milliseconds: 100),
    List<int> pattern = const [],
    int repeat = -1,
    List<int> intensities = const [1, 255],
    int amplitude = 128
  }) async {
    if(amplitude > 0 && !(await Vibration.hasAmplitudeControl()))  {
      amplitude = -1;
    }
    if (!(await Vibration.hasVibrator())) {
      return;
    }
    await Vibration.vibrate(
      duration: duration.inMilliseconds,
      pattern: pattern,
      repeat: repeat,
      intensities: intensities,
      amplitude: amplitude,
    );
  }
}